package demo1225.lianxi;

import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

/*
地铁案例
规则：从A站上车，到B站下车，计算付款金额
     0-6站           2元
     7-10站          3元
     11-14站         4元
     大于等于15站      5元
     用map集合
 */
public class Demo_02 {
    static Scanner scanner=new Scanner(System.in);
    public static void main(String[] args) {
        int i1 = Integer.parseInt("123");
        Map<Integer,String> l=new HashMap<>();
        String []a=new String[]{"南岗", "桂庄路", "汽车西站", "振兴路", "蜀山西", "大蜀山",
                "天柱路", "科学大道", "十里庙", "西七里塘", "五里墩", "三里庵",
                "安农大", "三孝口", "四牌楼", "大东门"};
        int count=1;
        int aa=0;
        int bb=0;
        for (String s : a) {
            l.put(count,s);
            count++;
        }
        System.out.println("请输入上车站点");
        String start = scanner.next();
        System.out.println("请输入终点站");
        String end=scanner.next();
        Set<Map.Entry<Integer, String>> set = l.entrySet();
        for (Map.Entry<Integer, String> i : set) {
            if(i.getValue().equals(start)){
                aa=i.getKey();
            }
            if(i.getValue().equals(end)){
                bb=i.getKey();
            }
        }

        int cc=aa-bb;
        int round = Math.round(cc);
        if(round<=2){
            System.out.println("2元");
        }else if(round<=7){
            System.out.println("3元");
        }else {
            System.out.println("5元");
        }
    }
    }

